package com.meicet.adapter.utils

import android.util.Log
import com.meicet.adapter.BaseAdapterConfig

// 4050 没超
// 4060 超了

@Suppress("TopLevelPropertyNaming")
private const val LogLength = 4000

@Suppress("FunctionNaming")
fun _i(tag: String, msg: String) {
    if (BaseAdapterConfig.debug) {
        val max = msg.length
        if (max > LogLength) {
            var maxMsg = msg
            var count = 0
            while (maxMsg.length > LogLength) {
                val printLog = maxMsg.substring(0, LogLength)
                maxMsg = maxMsg.substring(LogLength)
                Log.i(tag, "<[$count]>$printLog")
                count++
            }
            Log.i(tag, "<[$count]>$maxMsg")
        } else {
            Log.i(tag, msg)
        }
    }
}

@Suppress("FunctionNaming")
fun _i(msg: String) {
    _i("yyl", msg)
}

@Suppress("FunctionNaming")
fun _i(error: Exception) {
    if (BaseAdapterConfig.debug) {
        error.printStackTrace()
    }
}

@Suppress("FunctionNaming")
fun _ee(error: String) {
    _e("yyl", error)
}

@Suppress("FunctionNaming")
fun _e(error: String) {
    _e("yyl", error)
}

@Suppress("FunctionNaming")
fun _e(tag: String, error: String) {
    Log.e(tag, error)
}

@Suppress("FunctionNaming")
fun _e(error: Exception) {
    if (BaseAdapterConfig.debug) {
        error.printStackTrace()
    }
    // LogUtils.e(error)
}
